/**
 * http请求工具方法
 * name: kent
 */
angular.module('baseHttp', ['kt.httpUrlInterceptor'])
    .config(function ($httpProvider) {
        $httpProvider.interceptors.push('httpUrlInterceptor');//处理请求的url
    })
    .service('baseHttp', function ($q, $http) {

        return {
            get: function (url) {
                var def = $q.defer();
                $http.get(url).success(function (data) {
                    def.resolve(data);
                }).error(function (err) {
                    def.reject(err);
                });
                return def.promise;
            },

            //POST请求
            post: function (url, postData) {
                var def = $q.defer();
                $http.post(url, postData).success(function (data) {
                    def.resolve(data);
                }).error(function (err) {
                    def.reject(err);
                });
                return def.promise;
            }
        }
    });
